package org.apache.dubbo.demo.consumer.example.eg9;

import java.io.IOException;
import org.apache.dubbo.demo.example.eg9.DemoService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Application {

  public static void main(String[] args) throws IOException {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:example/eg9/applicationContext.xml");
    DemoService demoService = (DemoService) context.getBean("demoService");
    invoke(demoService);
    new Thread(() -> invoke(demoService)).start();
    System.in.read();
  }

  private static void invoke(DemoService demoService) {
    for (int i = 0; i < 10; i++) {
      String result = demoService.sayHello("xufeng");
      System.out.println("****************** result-" + i + ": " + result + " ******************");
    }
  }

}
